package com.exigenservices.demenkov.model.services.Impl;

import com.exigenservices.demenkov.model.dao.NewsDAO;
import com.exigenservices.demenkov.model.domain.News;
import com.exigenservices.demenkov.model.services.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Implementation for NewsService
 *
 * @Author DemYura
 * @Date 24.11.11
 */
@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    private NewsDAO newsDAO;


    @Transactional(readOnly = true)
    public News getNewsById(long id) {
        return newsDAO.get(id);
    }

    @Transactional(readOnly = true)
    public List<News> getAllNews() {
        return newsDAO.getAllNews();
    }

    @Transactional(readOnly = true)
    public List<News> getLatestNews(int count) {
        return newsDAO.getLatestNews(count);
    }

}
